<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>医嘱修改</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
    <style>
        ul li,
        ul li div div select,
        ul li div div input {
            font-size: 14px !important;
            ;
        }

        .aui-list-item-label {
            width: 220px !important;
            text-align: center;
        }

        .aui-list-item-input-small {
            width: 140px !important;
            position: relative;
        }

        input::-webkit-input-placeholder {
            /*Webkit browsers*/
            color: rgb(241, 11, 11);
            font-size: 16px;
        }

        input:-moz-placeholder {
            /*Mozilla Firefox 4 to 8*/
            color: rgb(241, 11, 11);
            font-size: 16px;
        }

        input::moz-placeholder {
            /*Mozilla Firefox 19+*/
            color: rgb(241, 11, 11);
            font-size: 16px;
        }

        input:-ms-input-placeholder {
            /*Internet Explorer 10+*/
            color: rgb(241, 11, 11);
            font-size: 16px;
        }

        .aui-list-item-input-small>input {
            width: 90px;
        }

        .aui-list-item-input-small>span {
            position: absolute;
            display: inline-block;
            height: 30px;
            top: 50%;
            right: 0;
            transform: translateY(-50%);
        }

        .aui-list-item-label-width {
            width: 530px !important;
        }

        .aui-list-item-input>label {
            margin-left: 10px;
        }

        .aui-radio {
            margin-right: 10px;
        }

        .aui-radio,
        .aui-checkbox {
            width: 25px !important;
            height: 25px !important;
            margin-right: 5px;
        }

        .textarea-container {
            width: 100%;
            margin: 0 auto;
        }

        .textarea-container>div:nth-child(1) {
            text-align: center;
            font-size: 17px;
        }

        .textarea-container>div:nth-child(2) {
            padding: 10px;
        }

        .textarea-wrapper {
            min-height: 100px;
            border: 1px solid rgba(0, 0, 0, 0.3);
            width: 97%;
            margin: 20px auto 5px auto;
            border-radius: 5px;
        }

        .submit-btn-bottom {
            font-size: 16px;
            margin: 30px auto;
            text-align: center;
        }

        .submit-btn-bottom>button {
            border: none;
            outline: none;
            background-color: #0064B0;
            height: 50px;
            width: 150px;
            color: #fff;
        }
    </style>
</head>

<body>
    <main id="app">
        <div class="aui-content aui-margin-b-15">
            <ul class="aui-list aui-form-list">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner" style="justify-content: flex-start;">
                        <div class="aui-list-item-label" style="width: 130px !important;">
                            管道
                        </div>
                        <div class="aui-list-item-input aui-list-item-input-small">
                            <div class="aui-list-item-input" id="moTheConduit" style="width:600px">

                            </div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <div>
            <div class="submit-btn-bottom">
                <!-- <button id="Preservatio" onclick="getHoMedicalOrder()">查看</button> -->
                <button id="Preservatio" onclick="updateHoMedicalOrder()">修改</button>
            </div>
        </div>
    </main>
</body>

</html>

<script src="../script/api.js" charset="utf-8" type="text/javascript"></script>
<script src="../script/vue.js" charset="utf-8" type="text/javascript"></script>
<script src="../js/jquery.min.js" charset="utf-8" type="text/javascript"></script>
<script src="../js/ToConfigure.js" charset="utf-8" type="text/javascript"></script>
<script src="../script/aui-toast.js" charset="utf-8" type="text/javascript"></script>
<script src="../script/aui-dialog.js" charset="utf-8" type="text/javascript"></script>
<script src="../script/aui-tab.js" charset="utf-8" type="text/javascript"></script>
<script type="text/javascript">
    // function ceshishi() {
    //     alert($("#corRemarks").text());
    // }

    window.apiready = function () {
        /**
         * 查询当前信息
         * */
        getHoMedicalOrder();
        Dictionaries()
    }
    var vm;
    apiready = function () {
        vm = new Vue({
            el: '#app',
            data: {
                checked: false,
                Url_IP: "",
                Query_UserList: [], //舱室操舱人员信息
                OperatinRecord: [], //舱次信息
                DictionaryLibrary: [],
                F_Id: 0,
                ParameterIdentification: 0, //0为修改   1为添加
            },
            created() {

                //获取医嘱患者Id
                this.moTrId = api.pageParam.moTrId;
                //判断是否获取到舱室Id
                if (this.moTrId !== "0") {
                    getHoMedicalOrder();
                    Dictionaries();

                }
            },
            methods: {

            }
        });
    }

    //获取信息
    function loaging() {
        getHoMedicalOrder();
    }
    /**
 * 查询医嘱
 * @param currPage 当前页
 */
    function getHoMedicalOrder() {
        //定义toast提示框
        var toast = new auiToast();
        var Url_IP = ToConfigure_IP("Gorgeous");
        var jsParms = new Object();
        /**
        * 舱次唯一标识
        */
        jsParms.moTrId = api.pageParam.moTrId;
        /**
          * 验证是否为空
          */
        if (jsParms.moTrId == 0 || jsParms.moTrId == undefined || jsParms.moTrId == null) {
            return;
        }
        /**
         * 请求控制器
         */
        $.ajax({
            url: Url_IP + '/businessmanagement/homedicalorder/getHoMedicalOrder',
            type: 'post',
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(jsParms),
            success: function (result) {
                /**
                 * 验证返回信息是否为空
                 */
                if (result.success == true) {
                    /**
                     *  循环object
                     */
                    $.each(result.data.list, function (i, o) {
                        /**
                         *管道
                         */
                        var moTheConduitList = o.moTheConduit.split(',');
                        /**
                         * 循环赋值
                         */
                        moTheConduitList.forEach(function (p) {
                            $("input:checkbox[value='" + p + "'][name = 'moTheConduit']").attr("checked", true);
                        });
                    })
                } else {
                    /**
                             *  提示错误信息
                             */
                    toast.fail({
                        title: "提交失败",
                        duration: 2000
                    });
                }
            },
            error: function (result) {
                /**
                             *  提示错误信息
                             */
                toast.fail({
                    title: "提交失败",
                    duration: 2000
                });
            }
        });
    }

    /**
     * 查询字典业务
     * 
    */
    function Dictionaries() {
        //操舱者2
        var moTheConduit = "";
        //定义toast提示框
        var toast = new auiToast();
        var Url_IP = ToConfigure_IP("Gorgeous");
        $.ajax({
            url: Url_IP + '/businessmanagement/hocabinoperationrecord/dictionariesApp',
            type: 'post',
            async: false,
            contentType: "application/json",
            dataType: "json",
            data: {},
            success: function (result) {
                /**
                 * 验证返回信息是否为空
                 */
                if (result.data.list.length > 0) {
                    /**
                     *  循环object
                     */
                    $.each(result.data.list, function (i, o) {
                        if (o.dictionariesType === 197) {
                            // 管道
                            moTheConduit += "<input class='aui-checkbox' name=moTheConduit type='checkbox' value=\"" + o.dictionariesName + "\">" + o.dictionariesName;
                        }
                    })
                    //管道
                    $("#moTheConduit").html(moTheConduit);

                } else {

                }
            },
            error: function (result) {

            }
        });
    }

    /**
 * 修改医嘱
 */
    function updateHoMedicalOrder() {
        //定义toast提示框
        var toast = new auiToast();
        var Url_IP = ToConfigure_IP("Gorgeous");
        /**
          * 参数
          * 
          * */
        var JsonStr = parameters(2);
        /**
         * 请求控制器
         */
        $.ajax({
            url: Url_IP + '/businessmanagement/homedicalorder/updateHoMedicalOrder',
            type: 'post',
            contentType: "application/json",
            dataType: "json",
            data: JsonStr,
            success: function (result) {
                /**
                 * 验证返回信息是否为空
                 */
                if (result.success == true) {

                    /**
                     * 操作成功提醒
                     */
                     JumpPage();
                } else {
                    /**
                     *  提示错误信息
                     */
                    toast.fail({
                        title: "提交失败",
                        duration: 2000
                    });
                }
            },
            error: function (result) {
                /**
                 *  提示错误信息
                 */
                toast.fail({
                    title: "提交失败",
                    duration: 2000
                });
            }
        })
    }


    /**
 * 获取参数
 */
    function parameters(type) {
        /**
         * 组合条件
         * @type {Object}
         */
        var jsParms = new Object();
        /**
         * 验证状态
         */
        if (type == 2) {
            /**
             * 获取医嘱唯一标识
             * @type {jQuery}
             */
            jsParms.moId = api.pageParam.moId;
        }

           /**
            *医嘱表患者id
            */
        jsParms.moTrId = api.pageParam.moTrId;
        /**
         * 
         * 修改人
         * @type {jQuery}
         */
        // jsParms.trMoOperator1=$("#moOperator1").val();
        /**
         *管道
         */
        var moTheConduit = [];
        $('input[name=moTheConduit]:checked').each(function () {
            /**
             * 追加数组
             */
            moTheConduit.push($(this).val());
        });
        /**
         * 数组转换成字符串
         */
        jsParms.moTheConduit = moTheConduit.join(',');
        /**
         * 返回JSON类型数据
         */
        return JSON.stringify(jsParms);
    }

    function reloadPatient() {
        //执行关闭患者信息窗口
        Cancel();
        window.location.reload();
    }
     //取消按钮
     function Cancel() {
        // vm.AddPersonnel = false;
        $('#cabin-info').hide();
    }

      //跳转页面
      function JumpPage() {
        var dialog = new auiDialog();
        dialog.alert({
            title: "提示",
            msg: '操作成功，是否跳转',
            buttons: ['取消', '确定']
        }, function (ret) {
            if (ret.buttonIndex === 1) {

            } else if (ret.buttonIndex === 2) {
                api.historyBack({}, function (ret, err) {

                    if (!ret.status) {
                        api.closeWin();
                    }
                });

                api.sendEvent({
                    name: 'On_Site_Inspection',
                    extra: {
                        state: 'no'
                    }
                });
            }
        })
    }

    function closewin() {
        api.closeWin({
            name: 'patientFrame'
        });
    }
</script>